package reflect;

import reflect.annotation.AutoRunClass;

import java.io.File;
import java.net.URISyntaxException;

public class Test3 {
    public static void main(String[] args) throws URISyntaxException, ClassNotFoundException {
        File dir = new File(
                Test3.class.getResource(".").toURI()
        );
        String packName = Test3.class.getPackage().getName();
        File[] subs = dir.listFiles(f -> f.getName().endsWith(".class"));
        for (File sub : subs) {
            String fileName = sub.getName();
            String className = fileName.substring(0, fileName.indexOf("."));
            Class cls = Class.forName(packName + "." + className);
            if (cls.isAnnotationPresent(AutoRunClass.class)) {
                System.out.println(cls.getName() + "被标注了");
            }
        }
    }
}
